home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 21
/
Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso
/
Aminet
/
util
/
cdity
/
availmem2.lha
/
AvailMem2
/
src
/
AvailMem2_settings.s
< prev
next >
Wrap
Text File
|
1997-07-01
|
18KB
|
748 lines
machine 68020
* program includes
include "AvailMem2_gui.i"
include "AvailMem2.i"
include "lvo.i"
incdir "include:"
include "exec/exec.i"
include "dos/dos.i"
include "dos/dosextens.i"
include "libraries/gadtools.i"
* config structure
STRUCTURE ProgramConfig,0
LONG cfg_IDString
LONG cfg_CfgVersion
LONG cfg_ChipDisplayed
LONG cfg_FastDisplayed
LONG cfg_PublicDisplayed
LONG cfg_CPUDisplayed
LONG cfg_RenderPercentage
LONG cfg_RenderLines
LONG cfg_LargMemBlkColour
LONG cfg_RemaMemBlkColour
LONG cfg_VBLDelay
LONG cfg_FlushButtons
LONG cfg_MinimizeBorders
LONG cfg_RemoveBorder
LONG cfg_AlwaysOnTop
LONG cfg_GoBackdrop
WORD cfg_MDLeftEdge
WORD cfg_MDTopEdge
WORD cfg_MDWidth
WORD cfg_MDHeight
STRUCT cfg_WindowTitle,256
STRUCT cfg_ScreenName,256
LABEL cfg_SIZEOF
IDString equ "ACFG" ;config-file string-id
CfgVersion equ 7 ;config-file version-id
section code,code ;availmem code section
_HandleSettingsMsgs
* * * * * * * * * * * * * * * * * * * * *
* *
* Handles settings window msgs. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
clr.l .prg_SettingsClose ;reset window close variable
tst.l SettingsWnd ;check if settings window open
beq .no_SettingsWnd ;skip if not
.MsgLoop_Settings
move.l _GadToolsBase,a6 ;put gadtoolsbase in a6
move.l SettingsWnd,a0 ;get ptr to settings window
move.l wd_UserPort(a0),a0 ;get window userport
jsr _LVOGT_GetIMsg(a6) ;get any waiting message
move.l d0,ptr_TempMsg ;store msg
beq .no_SettingsWnd ;if no message, continue looping
move.l ptr_TempMsg,a4 ;put msg in a4
move.l im_Class(a4),d4 ;get msg class
* check setting gadgets
cmp.l #IDCMP_GADGETUP,d4 ;check if a gadget was pressed
bne .no_IDCMP_GADGETUP ;skip if not
move.l im_IAddress(a4),a3 ;get ptr to gadget int a3
move.w gg_GadgetID(a3),d4 ;get gadget id to d4
cmp.w #GDX_Ok,d4 ;check if Ok button pressed
bne .no_GDX_Ok ;skip if not
jsr _ReadSettingsGadgets ;modify settings
st.l .prg_SettingsClose ;set window close variable
clr.l d4 ;reset msg class
.no_GDX_Ok
cmp.w #GDX_Cancel,d4 ;check if Cancel button pressed
bne .no_GDX_Cancel ;skip if not
st.l .prg_SettingsClose ;set window close variable
clr.l d4 ;reset msg class
.no_GDX_Cancel
clr.l d4 ;reset msg class
.no_IDCMP_GADGETUP
cmp.l #IDCMP_CLOSEWINDOW,d4 ;check if closegadget was pressed
bne .not_IDCMP_CLOSEWINDOW ;skip if not
st.l .prg_SettingsClose ;set window close variable
clr.l d4 ;reset msg class
.not_IDCMP_CLOSEWINDOW
move.l _GadToolsBase,a6 ;put gadtoolsbase in a6
move.l ptr_TempMsg,a1 ;put tempmsg in a1
jsr _LVOGT_ReplyIMsg(a6) ;reply window msg
bra .MsgLoop_Settings ;loop message-reader
.no_SettingsWnd
tst.l .prg_SettingsClose ;check if win should close
beq .no_SettingsClose ;skip if it shouldn't
jsr _CloseGUI ;close program GUI
jsr _StoreSettings
jsr _RetrieveSettings
jsr _OpenGUI ;reopen GUI
tst.l d0 ;check if GUI-open succeeded
beq .Fail
.no_SettingsClose
movem.l (sp)+,d0-a6 ;pop all registers
clr.l d0 ;set exitcode to FALSE
rts ;return
.Fail
movem.l (sp)+,d0-a6 ;pop all registers
st.l d0 ;set exitcode to TRUE
rts ;return
.prg_SettingsClose ds.l 1
.prg_SettingsChanged ds.l 1
_ReadSettingsGadgets
* * * * * * * * * * * * * * * * * * * * *
* *
* Scans the settings-gadgets for *
* active preferences. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
* initialize gadget-reading
move.l _GadToolsBase,a6 ;put gadtoolsbase in a6
lea.l SettingsGadgets,a5 ;get ptr to gadgets into a5
lea.l _GadgetList,a4 ;get ptr to gadget-list into a4
lea.l tag_Output,a3 ;get ptr to multi-taglist into a3
lea.l prg_OutputValue,a2 ;get ptr to tag-output into a2
move.l a2,4(a3) ;set standard output variable
* get window title
.ReadSettings
move.l (a4)+,d0
tst.l d0
beq .End_Of_Gadgets
subq.l #1,d0 ;get correct gadget-value
move.l (a5,d0*4),a0 ;get ptr to gadget into a0
move.l SettingsWnd,a1 ;put ptr to settingswnd to a1
sub.l a2,a2 ;reset requester
lea.l tag_Output,a3 ;get ptr to multi-taglist into a3
move.l (a4)+,d4 ;get special gadget-tag into d4
move.l d4,(a3) ;set special gadget-tag
jsr _LVOGT_GetGadgetAttrsA(a6);get gadget attributes
move.l (a4)+,a1 ;get ptr to output variable into a0
cmp.l #GTST_String,d4
beq .string_gadget
move.l prg_OutputValue,(a1) ;get output from function
bra .ReadSettings
.string_gadget
move.l prg_OutputValue,a0 ;get output from function
jsr _StringCopy ;copy gadget string-buffer
bra .ReadSettings
.End_Of_Gadgets
movem.l (sp)+,d0-a6 ;pop all registers
rts ;return
_SetSettingsGadgets
* * * * * * * * * * * * * * * * * * * * *
* *
* Sets the settings-gadgets with the *
* active preferences. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
* initialize gadget-reading
move.l _GadToolsBase,a6 ;put gadtoolsbase in a6
lea.l SettingsGadgets,a5 ;get ptr to gadgets into a5
lea.l _GadgetList,a4
* set window title
.SetSettings
move.l (a4)+,d0
tst.l d0
beq .End_Of_Gadgets
subq.l #1,d0
move.l (a5,d0*4),a0 ;get ptr to string-gadget into a0
move.l SettingsWnd,a1 ;put ptr to settingswnd to a1
lea.l tag_Output,a3 ;get ptr to multi-taglist into a3
move.l (a4)+,(a3)
move.l (a4)+,a2
move.l (a2),d1
cmp.l #GTST_String,(a3)
bne .no_string_gadget
move.l a2,d1
.no_string_gadget
move.l d1,4(a3)
sub.l a2,a2 ;reset requester
jsr _LVOGT_SetGadgetAttrsA(a6);set gadget attributes
bra .SetSettings
.End_Of_Gadgets
movem.l (sp)+,d0-a6 ;pop all registers
rts ;return
_LoadSettings
* * * * * * * * * * * * * * * * * * * * *
* *
* Loads new preferences *
* *
* IN: a0 - ptr to filename. *
* *
* OUT: d0 - success. (=0 FAIL) *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ; Stack all registers
clr.l d4 ; Clear filehandle
move.l _DosBase,a6 ; Dosbase in a6
move.l a0,d1 ; Put configfile-name in d1
move.l #MODE_OLDFILE,d2 ; Do not create file, just open
jsr _LVOOpen(a6) ; Open config file
move.l d0,d4
tst.l d0
beq .Fail
move.l d4,d1 ; Put filehandle in d1
move.l #prg_MainConfig,d2 ; Put config-file ptr in d2
move.l #8,d3 ; Size enough to read header
jsr _LVORead(a6) ; Read header and version
lea.l prg_MainConfig,a0
cmp.l #IDString,(a0)+ ; Check if true
bne .Fail
cmp.l #CfgVersion,(a0)+ ; Check if version matches
bne .Fail
move.l d4,d1 ; Put filehandle in d1
move.l a0,d2 ; Put config-file ptr in d2
move.l #cfg_SIZEOF-8,d3 ; Size set to read all
jsr _LVORead(a6) ; Read rest of config-file
tst.l d0
bmi .Fail
move.l d4,d1
jsr _LVOClose(a6) ; Close config-file
movem.l (sp)+,d0-a6 ; Restore all registers
st.l d0 ; Return success
rts ; Exit procedure
.Fail
move.l d4,d1 ; Put filehandle in d1
tst.l d1 ; Check filehandle
beq .no_file_open ; Catch if not open
move.l d4,d1
jsr _LVOClose(a6) ; Close config-file
.no_file_open
movem.l (sp)+,d0-a6 ; Restore all registers
clr.l d0 ; Return failure
rts ; Exit procedure
_SaveSettings
* * * * * * * * * * * * * * * * * * * * *
* *
* Saves the latest stored settings. *
* *
* IN: a0 - ptr to filename. *
* *
* OUT: d0 - success. (=0 FAIL) *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d1-a6,-(sp) ;push all registers
move.l _DosBase,a6 ; DosBase in a6
lea.l prg_MainConfig,a1 ; Config datastruct in a1
move.l #IDString,cfg_IDString(a1); Set ID string
move.l #CfgVersion,cfg_CfgVersion(a1); Set version number
clr.l d4 ; Clear filehandle
clr.l d7 ; Set failure
move.l a0,d1 ; Put configfile-name in d1
move.l #MODE_NEWFILE,d2 ; create file
jsr _LVOOpen(a6) ; Open config file
move.l d0,d4
beq .Fail
move.l d4,d1 ; Put filehandle in d1
move.l #prg_MainConfig,d2 ; Put config-file ptr in d2
move.l #cfg_SIZEOF,d3 ; Size set to write all
jsr _LVOWrite(a6) ; write config-file
st.l d7 ; Set success
.Fail
move.l d4,d1 ; Put filehandle in d1
tst.l d1 ; Check filehandle
beq .no_file_open ; Catch if not open
jsr _LVOClose(a6) ; Close config-file
.no_file_open
move.l d7,d0
movem.l (sp)+,d1-a6 ;pop all registers
rts ;return
_LoadMainPreferences
* * * * * * * * * * * * * * * * * * * * *
* *
* Shell to scan and load the program *
* settings. *
* *
* OUT: d0 - success. (=0 FAIL) *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
lea.l _ENVName,a0
jsr _FindDevice
tst.l d0
beq .FindENVARC
lea.l _ENVName,a0
lea.l prg_ConfigFileBuffer,a1
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
move.b #":",(a1)+
move.l ptr_ConfigName,a0
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
lea.l prg_ConfigAttach,a0
jsr _StringCopy
lea.l prg_ConfigFileBuffer,a0
jsr _LoadSettings
tst.l d0
bne .PrefLoaded
.FindENVARC
lea.l _ENVARCName,a0
jsr _FindDevice
tst.l d0
beq .PrefNotLoaded
lea.l _ENVARCName,a0
lea.l prg_ConfigFileBuffer,a1
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
move.b #":",(a1)+
move.l ptr_ConfigName,a0
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
lea.l prg_ConfigAttach,a0
jsr _StringCopy
lea.l prg_ConfigFileBuffer,a0
jsr _LoadSettings
tst.l d0
beq .PrefNotLoaded
.PrefLoaded
movem.l (sp)+,d0-a6 ;pop all registers
st.l d0 ;set exitcode to TRUE
rts ;return
.PrefNotLoaded
jsr _StoreSettings ;restore config-area
movem.l (sp)+,d0-a6 ;pop all registers
clr.l d0 ;set exitcode to FALSE
rts ;return
_SaveMainPreferences
* * * * * * * * * * * * * * * * * * * * *
* *
* Shell to scan and save the program *
* settings. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
jsr _StoreSettings
lea.l _ENVName,a0
jsr _FindDevice
tst.l d0
beq .FindENVARC
lea.l _ENVName,a0
lea.l prg_ConfigFileBuffer,a1
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
move.b #":",(a1)+
move.l ptr_ConfigName,a0
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
lea.l prg_ConfigAttach,a0
jsr _StringCopy
lea.l prg_ConfigFileBuffer,a0
jsr _SaveSettings
.FindENVARC
lea.l _ENVARCName,a0
jsr _FindDevice
tst.l d0
beq .SkipSaving
lea.l _ENVARCName,a0
lea.l prg_ConfigFileBuffer,a1
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
move.b #":",(a1)+
move.l ptr_ConfigName,a0
jsr _StringCopy
move.l d0,a1
subq.l #1,a1
lea.l prg_ConfigAttach,a0
jsr _StringCopy
lea.l prg_ConfigFileBuffer,a0
jsr _SaveSettings
.SkipSaving
movem.l (sp)+,d0-a6 ;pop all registers
rts ;return
_RetrieveSettings
* * * * * * * * * * * * * * * * * * * * *
* *
* Reads and fills in the program *
* preferences from the settings-buffer. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
lea.l prg_MainConfig,a5 ;get pointer to prg-config into a5
* read settings from cfg-buffer
move.l cfg_ChipDisplayed(a5),prg_ChipDisplayed
move.l cfg_FastDisplayed(a5),prg_FastDisplayed
move.l cfg_PublicDisplayed(a5),prg_PublicDisplayed
move.l cfg_CPUDisplayed(a5),prg_CPUDisplayed
move.l cfg_RenderPercentage(a5),prg_RenderPercentage
move.l cfg_RenderLines(a5),prg_RenderLines
move.l cfg_LargMemBlkColour(a5),prg_LargMemBlkColour
move.l cfg_RemaMemBlkColour(a5),prg_RemaMemBlkColour
move.l cfg_GoBackdrop(a5),prg_GoBackdrop
move.l cfg_VBLDelay(a5),prg_VBLDelay
move.l cfg_FlushButtons(a5),prg_FlushButtons
move.l cfg_MinimizeBorders(a5),prg_MinimizeBorders
move.l cfg_RemoveBorder(a5),prg_RemoveBorder
move.l cfg_AlwaysOnTop(a5),prg_AlwaysOnTop
* copy window settings from buffer
move.w cfg_MDLeftEdge(a5),MemoryDisplayLeft
move.w cfg_MDTopEdge(a5),MemoryDisplayTop
move.w cfg_MDWidth(a5),MemoryDisplayWidth
move.w cfg_MDHeight(a5),MemoryDisplayHeight
* copy strings from buffer
lea.l cfg_WindowTitle(a5),a0
lea.l prg_WindowTitle,a1
jsr _StringCopy
lea.l cfg_ScreenName(a5),a0
lea.l prg_ScreenName,a1
jsr _StringCopy
movem.l (sp)+,d0-a6 ;pop all registers
rts ;return
_StoreSettings
* * * * * * * * * * * * * * * * * * * * *
* *
* Copies the settings to the program *
* config-structure. *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d0-a6,-(sp) ;push all registers
lea.l prg_MainConfig,a5 ;get pointer to prg-config into a5
* write settings to cfg-buffer
move.l #IDString,cfg_IDString(a5)
move.l #CfgVersion,cfg_CfgVersion(a5)
move.l prg_ChipDisplayed,cfg_ChipDisplayed(a5)
move.l prg_FastDisplayed,cfg_FastDisplayed(a5)
move.l prg_PublicDisplayed,cfg_PublicDisplayed(a5)
move.l prg_CPUDisplayed,cfg_CPUDisplayed(a5)
move.l prg_RenderPercentage,cfg_RenderPercentage(a5)
move.l prg_RenderLines,cfg_RenderLines(a5)
move.l prg_LargMemBlkColour,cfg_LargMemBlkColour(a5)
move.l prg_RemaMemBlkColour,cfg_RemaMemBlkColour(a5)
move.l prg_GoBackdrop,cfg_GoBackdrop(a5)
move.l prg_VBLDelay,cfg_VBLDelay(a5)
move.l prg_FlushButtons,cfg_FlushButtons(a5)
move.l prg_MinimizeBorders,cfg_MinimizeBorders(a5)
move.l prg_RemoveBorder,cfg_RemoveBorder(a5)
move.l prg_AlwaysOnTop,cfg_AlwaysOnTop(a5)
* copy window settings to buffer
move.w MemoryDisplayLeft,cfg_MDLeftEdge(a5)
move.w MemoryDisplayTop,cfg_MDTopEdge(a5)
move.w MemoryDisplayWidth,cfg_MDWidth(a5)
move.w MemoryDisplayHeight,cfg_MDHeight(a5)
* copy strings to buffer
lea.l prg_WindowTitle,a0
lea.l cfg_WindowTitle(a5),a1
jsr _StringCopy
lea.l prg_ScreenName,a0
lea.l cfg_ScreenName(a5),a1
jsr _StringCopy
movem.l (sp)+,d0-a6 ;pop all registers
rts ;return
_FindDevice
* * * * * * * * * * * * * * * * * * * * *
* Checks if a device really exists, *
* without getting complaining *
* requesters. *
* *
* IN: a0 - ptr to device name. *
* *
* OUT: d0 - Success. (=0 FAIL) *
* *
* * * * * * * * * * * * * * * * * * * * *
movem.l d1-a6,-(sp) ;stack all registers
move.l a0,a2 ;store device name in a2
move.l _DosBase,a6 ;dosBase in a6
move.l #(LDF_ALL!LDF_READ),d1 ;device flags
jsr _LVOLockDosList(a6) ;lock Doslist
move.l d0,.prg_DosList ;store DosList ptr
move.l .prg_DosList,d1 ;put DosList in d1
move.l a2,d2 ;put device name in d2
move.l #(LDF_ALL),d3 ;device flags
jsr _LVOFindDosEntry(a6) ;find device matching name
move.l d0,d7 ;store new Doslist-ptr
move.l #(LDF_ALL!LDF_READ),d1 ;device flags
jsr _LVOUnLockDosList(a6) ;unlock Doslist
move.l d7,d0 ;put result in d0
movem.l (sp)+,d1-a6 ;restore all registers
rts ;exit procedure
.prg_DosList ds.l 1
_ResetToDefaults
movem.l d0-a6,-(sp)
lea.l prg_MainConfig,a4
st.l cfg_ChipDisplayed(a4)
st.l cfg_FastDisplayed(a4)
clr.l cfg_PublicDisplayed(a4)
clr.l cfg_CPUDisplayed(a4)
clr.l cfg_RenderLines(a4)
clr.l cfg_RenderPercentage(a4)
clr.l cfg_FlushButtons(a4)
clr.l cfg_MinimizeBorders(a4)
clr.l cfg_RemoveBorder(a4)
clr.l cfg_AlwaysOnTop(a4)
clr.l cfg_GoBackdrop(a4)
move.l #3,cfg_LargMemBlkColour(a4)
move.l #2,cfg_RemaMemBlkColour(a4)
move.l #3-1,cfg_VBLDelay(a4) ;initalize delay variable
lea.l _DefWindowTitle,a0 ;get ptr to def. window-title into a0
lea.l cfg_WindowTitle(a4),a1 ;get ptr to mem-display window title
jsr _StringCopy
move.b #0,cfg_ScreenName(a4) ;reset screen-name
move.w #439,cfg_MDLeftEdge(a4)
move.w #11,cfg_MDTopEdge(a4)
move.w #201,cfg_MDWidth(a4)
move.w #27,cfg_MDHeight(a4)
movem.l (sp)+,d0-a6
rts
section data,data ;availmem data section
_GadgetList
dc.l 1+GDX_WindowTitle,GTST_String,prg_WindowTitle
dc.l 1+GDX_ScreenName,GTST_String,prg_ScreenName
dc.l 1+GDX_ChipMemory,GTCB_Checked,prg_ChipDisplayed
dc.l 1+GDX_FastMemory,GTCB_Checked,prg_FastDisplayed
dc.l 1+GDX_PublicMemory,GTCB_Checked,prg_PublicDisplayed
dc.l 1+GDX_CPUUsage,GTCB_Checked,prg_CPUDisplayed
dc.l 1+GDX_Seperative_Lines,GTCB_Checked,prg_RenderLines
dc.l 1+GDX_Percentage,GTCB_Checked,prg_RenderPercentage
dc.l 1+GDX_FlushButtons,GTCB_Checked,prg_FlushButtons
dc.l 1+GDX_GoBackdrop,GTCB_Checked,prg_GoBackdrop
dc.l 1+GDX_MinimizedBorders,GTCB_Checked,prg_MinimizeBorders
dc.l 1+GDX_RemoveBorders,GTCB_Checked,prg_RemoveBorder
dc.l 1+GDX_AlwaysOnTop,GTCB_Checked,prg_AlwaysOnTop
dc.l 1+GDX_LargestMemBlock,GTPA_Color,prg_LargMemBlkColour
dc.l 1+GDX_RemainingMemBlock,GTPA_Color,prg_RemaMemBlkColour
dc.l 1+GDX_RefreshRate,GTCY_Active,prg_VBLDelay
dc.l 0 ;end of list
* config names
_ENVName dc.b "ENV",0
_ENVARCName dc.b "ENVARC",0
* default window title
_DefWindowTitle dc.b "Available Memory",0
section bss,bss ;availmem bss section
prg_ChipDisplayed ds.l 1 ;program chipbar variable
prg_FastDisplayed ds.l 1 ;program fastbar variable
prg_PublicDisplayed ds.l 1 ;program publicbar variable
prg_CPUUsage ds.l 1 ;program CPU usage variable
prg_CPUDisplayed ds.l 1 ;program CPU display variable
prg_RenderPercentage ds.l 1 ;program render percentage bool
prg_RenderLines ds.l 1 ;program renderlines bool
prg_LargMemBlkColour ds.l 1 ;colour of largest memoryblock
prg_RemaMemBlkColour ds.l 1 ;colour of remaining memoryblock
prg_VBLDelay ds.l 1 ;Program VBL delay between checks
prg_FlushButtons ds.l 1 ;program flushbuttons bool
prg_MinimizeBorders ds.l 1 ;program smallwindow bool
prg_RemoveBorder ds.l 1 ;program remborders bool
prg_AlwaysOnTop ds.l 1 ;program on top bool
prg_GoBackdrop ds.l 1 ;program backdrop bool
prg_WindowTitle ds.b 256 ;mem-display window title
prg_ScreenName ds.b 256 ;program popup screen-name
* preference name pointers
ptr_ProgramConfig ds.l 1 ;ptr to ENV config-name
ptr_StaticConfig ds.l 1 ;ptr to ENVARC config-name
* multipurpose Gadtools taglist
prg_OutputValue ds.l 1
tag_Output
dc.l 0,0
dc.l TAG_END ;Ok, BSS, but TAG_END=0 anyway.. :)
prg_MainConfig ds.b cfg_SIZEOF;program config area
prg_ConfigFileBuffer ds.b 256